from rich.console import Console
from rich.layout import Layout
from rich.panel import Panel
from rich.text import Text
import time

console = Console()

def make_layout():
    # 创建一个没有边距的布局
    layout = Layout(minimum_size=50)
    
    # 顶部导航栏和主内容区垂直分割，设置零间距
    layout.split_column(
        Layout(Panel(Text("顶部导航", justify="center"), height=3, style="on blue", border_style="white", padding=0), name="header", ratio=0, minimum_size=3),
        Layout(name="main", ratio=8)
    )
    
    # 主内容区水平分割为侧边栏和工作区，设置零间距
    layout["main"].split_row(
        Layout(Panel("侧边栏", style="on dark_blue", border_style="white", padding=0, height=20), name="sidebar", ratio=1, minimum_size=15),
        Layout(name="content", ratio=4)
    )
    
    # 工作区内容，设置零边距
    layout["main"]["content"].update(
        Panel(
            "主内容区域",
            title="工作区",
            border_style="green",
            padding=0,
            height=20
        )
    )
    
    return layout

layout = make_layout()
console.print(layout)